<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.1</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
    <script type="text/javascript" src="/js/cookie.js"></script>

    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
</head>

<body>

<div class="x-body">
    <div class="layui-row">

        <div class="demoTable">
            <div class="layui-row">
                <button id="add" class="layui-btn add" ><i class="layui-icon"></i>添加价格
                </button>
                <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
                   href="javascript:location.replace(location.href);" title="刷新">
                    <i class="layui-icon" style="line-height:30px">刷新</i></a>
            </div>
        </div>
                <div class="layui-row">
                    <form class="layui-form layui-col-md12  layui-form-pane">
                        <div class="layui-form-item" id="x-city">
                            <div class="layui-input-inline" >
                                <select name="roomType" id="roomType">
                                    <option value="">房间类型</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <input class="layui-input" placeholder="请选择时间" name="searchTime" id="searchTime" autocomplete="off">
                            </div>
                            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
    </div>

    <div class="layui-row">
        <div class="layui-btn-container">
            <button class="layui-btn" lay-event="" data-value="1">显示单日历</button>
        </div>
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-warm" lay-event="" data-value="2">显示双日历</button>
        </div>
    </div>
</div>
<script src="/js/calendarConfig.js"></script>
<script>
    layui.use(['form', 'jquery', 'table','laydate'], function () {
        YUI(config).use('price-calendar', function (Y) {
            //价格日历实例
            var oCalendar = new Y.PriceCalendar();
        });
        var $ = layui.$,
            form = layui.form,
            laydate = layui.laydate;
            table = layui.table;

        //搜索不同时间价格 日期时间选择器
        laydate.render({
            elem: '#searchTime'
        });

        //点击添加按钮，弹出编辑页面
        $("#add").click(function () {
            var w=($(window).width()*0.5);
            var h=($(window).height() - 70);
            console.log('w:'+w+',h:'+h);
            layer.open({
                type: 1,
                area: [w+'px', h +'px'],
                fix: false, //不固定
                maxmin: true,
                shadeClose: true,
                shade:0.4,
                title: "添加",
                content: $("#addPricePage"),
                success: function(){
                    console.log('success');
                }
            });
        });

        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'delAll':
                    layer.confirm('真的删除行么', function (index) {
                        var arr = [];
                        var data = checkStatus.data;
                        $.each(data, function (idx, obj) {
                            arr.push(obj.id);
                        });
                        //发异步
                        $.post("/roomPrice/remove", {'ids': arr.toString()}, function (res) {
                            if (res.status == 0) {
                                tableIns.reload();
                            }
                            else {
                                layer.alert("修改失败", {icon: 5})
                            }
                        });
                        layer.close(index);
                    })

                    break;
            };
        });


    });
    /*end use*/



</script>

<!--操作-->
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<!--头部工具栏-->
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-danger" lay-event="delAll"><i class="layui-icon"></i>批量删除</button>
    </div>
</script>


</body>
</html>